/**
 * Copyright (C) 2010 DustedPixels.com
 */
package com.dustedpixels.cirt.model.cpu.z80;

import com.dustedpixels.cirt.model.core.Circuit;
import com.dustedpixels.cirt.model.core.In;
import com.dustedpixels.cirt.model.core.Out;
import com.dustedpixels.cirt.model.core.Pins;
import com.dustedpixels.cirt.model.core.Script;

/**
 * AddressBus
 *
 * @author Michal Pociecha-Los (micapolos@gmail.com)
 */
@Circuit
public final class AddressBus {
  public static final int SELECT_PC = 0;
  public static final int SELECT_SP = 1;
  public static final int SELECT_REGS = 2;
  public static final int SELECT_IR = 3;
  
  @In @Pins(3) public int selectIn;
  
  @In @Pins(16) public int pcIn;
  @In @Pins(16) public int spIn;
  @In @Pins(16) public int regsIn;
  @In @Pins(16) public int irIn;
  
  @Out @Pins(16) public int out;
  
  @Script
  public void update() {
    switch (selectIn) {
      case SELECT_PC: 
        out = pcIn;
        break;
      case SELECT_SP: 
        out = spIn;
        break;
      case SELECT_REGS: 
        out = regsIn;
        break;
      case SELECT_IR: 
        out = irIn;
        break;
    }
  }
}
